-- beehive
-- created by panyl
-- 地牢格子：物品（可拾取类）

return {
    restoreGrid = function(grid, info)
        if not info or not info.beehive then
            if info.bonus then
                grid.bonus = info["bonus"];
                info["bonus"] = nil;
            end
            return;
        end

        grid.beehive = info.beehive;

        -- BeehiveM.initBeehive(info.beehive["id"], info.beehive["times"], grid:getPos());
        -- 还原奖励
        if info.bonus then
            grid.bonus = info["bonus"];
            info["bonus"] = nil;
        end
    end,

    -- 收集上下文
    collectContext = function(grid)
        local data = grid.beehive;

        if not data or data.times >= BeehiveM.query(data.id, "times") then
            return { ["state"] = GRID_STATE_DISABLE, ["bonus"] = grid.bonus};
        end

        return { ["beehive"] = data, ["bonus"] = grid.bonus};
    end,

    -- 自动战斗
    autoFight = function(grid)
        local pos = grid:getPos();
        return DungeonActionM.go("beehive", pos);
    end,
};
